#pragma once


#include "flui/wubi_ui_fl.h"
#include "UIIpcClient.h"
#include "CodeTableEditUI.h"

class WubiUI
{
public:
    WubiUI();
    ~WubiUI();

    void init();
    void show();

private:
    // 新增回调声明
    static void onDeleteCodeTable(Fl_Widget*, void*);
    static void onMoveUpCodeTable(Fl_Widget*, void*);
    static void onMoveDownCodeTable(Fl_Widget*, void*);
    static void onReloadCodeTable(Fl_Widget*, void*);
    static void onEditCodeTable(Fl_Widget*, void*);
    static void onRemoveScheme(Fl_Widget*, void*);
    static void onAddCodeTableConfirm(Fl_Widget*, void*);
    static void onAddCodeTableCancel(Fl_Widget*, void*);
    static void onAddSchemeConfirm(Fl_Widget*, void*);
    static void onAddSchemeCancel(Fl_Widget*, void*);
    static void onActiveScheme(Fl_Widget*, void*);
    static void onShowAddScheme(Fl_Widget*, void*);
    static void onShowAddCodeTable(Fl_Widget*, void*);
    static void onImportFile(Fl_Widget*, void*);
    static void onTabChage(Fl_Widget*, void*);
    static void onCodeTableEnable(Fl_Widget*, void*);

    static void onSearchWordCode(Fl_Widget*, void*); //编码反查
    static void onExportCodeTable(Fl_Widget*, void*); //导出码表

    static void onSchemeItemClick(Fl_Widget*, void*);

private: 
    void reloadScheme(); // 重新加载方案数据
    
    UIIpcClient _ui_ipc_client;
    WubiUIMainWindow _main_window;
    AddSechemeWindow _add_scheme_window;
    AddCodeTableView _add_code_table_window;

    CodeTableEditUI _code_table_edit_ui; // 新增的CodeTableEditUI对象

    unsigned int _current_scheme_id; // 当前激活的方案id，0表示没有激活的方案，即没有wub
    std::vector<UIBaseInfo> _schemes; // 存储方案信息
    std::vector<UIBaseInfo> _code_tables; // 存储码表信息
    int     _last_selected_scheme_id; // 记录上次选中的方案id
};